package com.app.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.app.R;
import com.app.bean.MyBean;

import java.util.List;

public class MyAdapter extends BaseAdapter {
    List<MyBean.ListBean> list;
    Context context;

    public MyAdapter(List<MyBean.ListBean> list, Context context) {
        this.list = list;
        this.context = context;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_listview, parent, false);
         TextView textView1 = view.findViewById(R.id.textview1);
         TextView textView2 = view.findViewById(R.id.textview2);

         MyBean.ListBean listBean = list.get(position);
         textView1.setText(listBean.getTitle());
         textView2.setText(listBean.getDate()+"");
         return view;
    }}